﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    class Particle : BaseObject
    {
        public float m_fLife;
        public Vector2 m_MinSize = new Vector2(0.0f, 0.0f);
        public Vector2 m_MaxSize = new Vector2(1.0f, 1.0f);

        public Particle()
        {
            m_Texture = GlobalContentManager.Instance.Texture("Glow");
        }

        public Particle(Particle other)
        {
            m_Texture = other.m_Texture;
            m_Velocity = other.m_Velocity;
            m_Position = other.m_Position;
            m_fLife = other.m_fLife;
            m_Scale = new Vector2(GlobalContentManager.Instance.RandomFloat(m_MinSize.X, m_MaxSize.X),
                                  GlobalContentManager.Instance.RandomFloat(m_MinSize.Y, m_MaxSize.Y));
            m_Scale.X = m_Scale.Y;
        }

        public override void Render(SpriteBatch spriteBatch, Camera cam)
        {
            spriteBatch.Draw(m_Texture, new Rectangle((int)m_Position.X - 16 - (int)cam.m_Position.X, (int)m_Position.Y - 16 - (int)cam.m_Position.Y, (int)(32*m_Scale.X), (int)(32*m_Scale.Y)), Color.Green);
        }

        public override void Update(float deltaT, KeyboardState LastKeyState)
        {
            m_Position += m_Velocity * deltaT;
            m_fLife -= deltaT;
            if (m_fLife <= 0.0f)
            {
                m_bIsAlive = false;
            }
        }

        public override void CollisionResponse(BaseObject other)
        {
            
        }
    }
}
